/**
 * @file Define Web application default handlers
 *
 * @author Steve Gao<gaofu@parllay.com>
 */

const WebBaseController = require('./web-base-controller');
const SystemServices = require('../../constants').SystemServices;

/**
 * The administration controller class
 *
 * @class AdminController
 * @extends {WebBaseController}
 */
class AdminController extends WebBaseController {

    get adminService() {
        if (!this._adminService) {
            this._adminService = this.getSystemService(SystemServices.ADMIN_SERVICE);
        }

        return this._adminService;
    }

    get handlersPath() {
        return 'admin';
    }

    get name() {
        return "AdminController";
    }

    /**
     *
     * 验证登录用户
     * @param {*} userName
     * @param {*} password
     * @param {*} parentCallback
     */
    verifyUser(userName, password, parentCallback) {
        this.adminService.verifyUser(userName, password, (result) => {
            parentCallback(result);
        })
    }

    /**
     *
     * 设置页的搜索店员和门店接口
     * @param {*} params
     * @param {*} parentCallback
     */
    commonSearch(params, parentCallback) {
        this.adminService.commonSearch(params, (result) => {
            parentCallback(result);
        })
    }
    
    dingstoreSearch(params, parentCallback) {
        this.adminService.dingstoreSearch(params, (result) => {
            parentCallback(result);
        })
    }

    activeSearch(params, parentCallback) {
        this.adminService.activeSearch(params, (result) => {
            parentCallback(result);
        })
    }

    goodsSearch(params, parentCallback) {
        this.adminService.goodsSearch(params, (result) => {
            parentCallback(result);
        })
    }
    getGoodlistById(params, parentCallback) {
        this.adminService.getGoodlistById(params, (result) => {
            parentCallback(result);
        })
    }

    doAjax(datas, parentCallback) {
        this.adminService.doAjax(datas, (result) => {
            parentCallback(result);
        })
    }

}

exports.AdminController = AdminController;